<?php

class ActiveController extends Zend_Controller_Action
{
    public function init()
    {
    	
    }

    public function listtypeAction()
    {  	
    	$db = new Model_DbTable_flux_acti();    	 
    	$arr = $db->getAll();    	 
    	$this->view->data = $arr;
    }
    
    public function listAction()
    {
    	$db = new Model_DbTable_flux_actiuti();
    	$arr = $db->getAll();
    	$this->view->data = $arr;
    }
    
    public function addAction()
    {
    	if ($this->getRequest ()->isPost ()) 
    	{
    		$code= $this->getRequest()->getPost('txtCode');    		
    		$desc = $this->getRequest()->getPost('txtDesc');
    		
    		$db = new Model_DbTable_flux_acti();
    		$uid = $db->ajouter(array("code"=>$code
    				//, "desc"=>$desc
    				)); 	
    		
    		//$this->_redirect ('/user/detail/id/'. $login);
    		$this->_redirect ('/active/list');
    	}    
    	else 
    	{    	
    		$this->view->title = "Welcome";    	
    		$this->render ();    	
    	}    	 
    }  
   
    public function supprimerAction()
    {
    	$id = $this->getRequest()->getParam('id');
    	$db = new Model_DbTable_flux_acti();
    	$db->remove($id);
    	$this->_redirect ('/active/list');
    }
    
    public function supprimertypeAction()
    {
    	$aid = $this->getRequest()->getParam('aid');
    	$uid = $this->getRequest()->getParam('uid');
    	$db = new Model_DbTable_flux_actiuti();
    	$db->remove($id); //il y a bug ici, 
    	$this->_redirect ('/active/list');
    }
    
    public function modifyAction()
    {
    	if ($this->getRequest ()->isPost ())
    	{
	    	$id = $this->getRequest()->getPost('txtId');
	    	$login = $this->getRequest()->getPost('txtLogin');
	    	$maj = $this->getRequest()->getPost('txtMaj');
	    	$flux = $this->getRequest()->getPost('txtFlux');
	    	$mdp = $this->getRequest()->getPost('txtMdp');
	    	$role = $this->getRequest()->getPost('txtRole');
	    	$mdpSel = $this->getRequest()->getPost('txtMdpSel');
	    	$mail = $this->getRequest()->getPost('txtMail');
	
	    	$db = new Model_DbTable_flux_acti();
	    	$db->edit($id, array("login"=>$login, "maj"=>$maj, "flux"=>$flux,
	    			"mdp"=>$mdp, "role"=>$role, "mdp_sel"=>$mdpSel,
	    			"email"=>$mail
	    	));
	
	    	$this->_redirect ('/user/list');
    	}
    }
    
}